//index.js
//获取应用实例
const app = getApp()

Page({
    data: {
        userInfo: '',
        StatusBar: app.globalData.StatusBar,
        CustomBar: app.globalData.CustomBar,
        Custom: app.globalData.Custom,
        hasUserInfo: false,
        canIUse: wx.canIUse('button.open-type.getUserInfo'),
        TabCur: 1,
        scrollLeft: 0,

        navigate: [{
            url: "/pages/index/index",
            type: "switchTab",
            text: "返回首页",
            color: "#5677fc"
        }]

    },
    onLoad() {
        // 保存信息在本地，下次免授权登录
        let userInfo = wx.getStorageSync('userInfo')
        this.setData({
            userInfo: userInfo,
        })
    },
    login() {
        wx.getUserProfile({
            desc: '使用户得到更好的体验', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
            success: res => {
                console.log(res)
                let userInfo = res.userInfo
                wx.setStorageSync('userInfo', userInfo)
                this.setData({
                    userInfo: userInfo,
                })
            },
            fail: res => {
                console.log("获取用户信息失败", res)
            }
        })
    },

    showModal(e) {
        this.setData({
            modalName: e.currentTarget.dataset.target
        })
    },
    hideModal(e) {
        this.setData({
            modalName: null
        })
    },
    tabSelect(e) {
        console.log(e);
        this.setData({
            TabCur: e.currentTarget.dataset.id,
            scrollLeft: (e.currentTarget.dataset.id - 1) * 60
        })
    },
    log() {
        wx.navigateTo({
            url: '../mine/log/log'
        })
    }

})